package com.lizard.schedule.ui.activity.base;

import android.os.Bundle;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.wearable.Wearable;

/**
 * 特性:
 * 1、继承{@link BaseActivity}中的所有特性
 * 2、自动构建{@link #googleApiClient}属性 并在{@link #onResume()}中连接 在{@link #onPause()}中断开
 *
 * Created by wangyiqian on 16/6/12.
 */
public class BaseGoogleApiClientActivity extends BaseActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {

    protected GoogleApiClient googleApiClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        googleApiClient = new GoogleApiClient.Builder(this)
                .addApi(Wearable.API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
    }

    @Override
    protected void onResume() {
        super.onResume();
        googleApiClient.connect();
    }

    @Override
    protected void onPause() {
        super.onPause();
        googleApiClient.disconnect();
    }

    /**
     * googleApiClient连接成功
     *
     * @param bundle
     */
    @Override
    public void onConnected(Bundle bundle) {

    }

    /**
     * googleApiClient连接挂起
     *
     * @param i
     */
    @Override
    public void onConnectionSuspended(int i) {

    }

    /**
     * googleApiClient连接失败
     *
     * @param connectionResult
     */
    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {

    }
}
